﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AntMovement.Core.Logic
{
    public class Ton
    {
        private bool _statusLock = false;
        public bool Out { get; set; }
        private DateTime _startTime = DateTime.Now, _endTime = DateTime.Now;
        public void Time(long ms, bool bl)
        {
            if (bl && !_statusLock)
            {
                _startTime = DateTime.Now;
                _statusLock = true;
            }
            if (bl && _statusLock)
            {
                _endTime = DateTime.Now;
            }
            if (!bl && _statusLock)
            {
                _startTime = DateTime.Now;
                _endTime = DateTime.Now;
                _statusLock = false;
            }
            TimeSpan difference = _endTime - _startTime;
            if (difference.TotalMilliseconds < ms)
            {
                Out = false;
                return;
            }
            Out = true;
        }
    }
}
